A key part of USB device architecture is the definition of the device's class, which describes the device's function, such as:
- Mass Storage
- Audio
- Human Interface Device (HID)
- Hub
- Communication Device Class (CDC)
- Video
The USB Implementers Forum (USB-IF) defines each device class in separate specifications.
These class specifications describe:
- The collection of endpoints used by the device
- The programming interface exposed to the host
- Class-specific control requests
- Data formats
- Additional requirements
Endpoints
An endpoint is the fundamental communication unit in a USB device. Every USB device must implement Endpoint 0 (the Default Control Pipe).
Endpoint Characteristics
| Property | Description |
|---|---|
| Address | 4-bit number (0–15) |
| Direction | IN (device → host) or OUT (host → device) |
| Transfer Type | Control, Bulk, Interrupt, or Isochronous |
| Max Packet Size | Maximum bytes per transaction |
Endpoint 0 is bidirectional and always uses Control transfer type. All other endpoints are unidirectional.
Maximum Endpoints
- A USB device can have up to 16 IN and 16 OUT endpoints (including endpoint 0)
- In practice, most devices use far fewer
Pipes
A pipe is a logical connection between a host memory buffer and a device endpoint. Two types exist:
- Stream Pipe — Carries data with no USB-defined structure (Bulk, Interrupt, or Isochronous transfers)
- Message Pipe — Carries structured USB requests (Control transfers only; always uses Endpoint 0)
Transfer Types
| Transfer Type | Use Case | Error Recovery | Guaranteed Bandwidth | Latency |
|---|---|---|---|---|
| Control | Device configuration, commands | Yes (retries) | No | Variable |
| Bulk | Large data (storage, printers) | Yes (retries) | No | Variable |
| Interrupt | Small, periodic data (keyboard, mouse) | Yes (retries) | Yes | Bounded |
| Isochronous | Time-sensitive streaming (audio, video) | No retries | Yes | Bounded |
Device Class Hierarchy
Device Class (e.g., Mass Storage)
├── Subclass (e.g., SCSI Transparent Command Set)
│ └── Protocol (e.g., Bulk-Only Transport)
- Class code — Defines the broad function category
- Subclass code — Narrows the specific type within the class
- Protocol code — Specifies the exact protocol variant
These codes are reported in either the Device Descriptor or the Interface Descriptor, depending on where the class is defined.
Common Device Classes
| Class Code | Class Name | Example Devices |
|---|---|---|
0x00 |
Defined at Interface level | Composite devices |
0x01 |
Audio | USB microphones, speakers |
0x02 |
CDC (Communications) | USB modems, serial adapters |
0x03 |
HID | Keyboards, mice, game controllers |
0x08 |
Mass Storage | USB flash drives, external HDDs |
0x09 |
Hub | USB hubs |
0x0E |
Video | USB webcams |
0xFF |
Vendor Specific | Custom/proprietary devices |
Composite vs. Compound Devices
-
Composite Device — A single device with multiple interfaces, each potentially a different class
- Example: USB headset with Audio (speaker + microphone) + HID (volume buttons)
- Each interface can be bound to a separate driver
-
Compound Device — A physical device containing an embedded hub and one or more connected functions
- Appears as multiple separate devices to the host
- Less common than composite devices